using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace ConsoleApplication2.Models.Mapping
{
    public class PT_ProcedureMap : EntityTypeConfiguration<PT_Procedure>
    {
        public PT_ProcedureMap()
        {
            // Primary Key
            this.HasKey(t => t.PTSP_ID);

            // Properties
            // Table & Column Mappings
            this.ToTable("PT_Procedure");
            this.Property(t => t.PTSP_ID).HasColumnName("PTSP_ID");
            this.Property(t => t.PTSP_Procedure).HasColumnName("PTSP_Procedure");
            this.Property(t => t.PTSP_Note).HasColumnName("PTSP_Note");
            this.Property(t => t.PTSP_SessionID).HasColumnName("PTSP_SessionID");

            // Relationships
            this.HasOptional(t => t.PT_Session)
                .WithMany(t => t.PT_Procedure)
                .HasForeignKey(d => d.PTSP_SessionID);
            this.HasOptional(t => t.TRT_Procedure)
                .WithMany(t => t.PT_Procedure)
                .HasForeignKey(d => d.PTSP_Procedure);

        }
    }
}
